<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

	<!--添加需要搜索的工具  -->
	<div id="huotb4" style="padding: 5px; height: auto">
		<div>
			<a id="huoadd4" href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true">添加</a> <a
				href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
			 <sapn style="margin-left:60%">搜索文本：</sapn> <input id="holidayname" class="easyui-searchbox" data-options="searcher:searchname,prompt:'请输入需要搜索的名称'"
				style="width: 20%">
		</div>
	</div>
	<table id="huodg4" class="easyui-datagrid"></table>
	<!-- 弹出新增窗口代码开始 -->
	<div id="huodd4" class="easyui-dialog"
		style="width: 600px; height: 300px"
		data-options="modal:true,closed:true,title:'添加假种信息'">
		<form id="ff" method="post" action="addemp">
			<div id="holidaybody" style="margin: 2% 20%">
			<input class="easyui-textbox " type="text" style="display:none;width:10px;" id="holidayId"/>
			<input class="easyui-textbox " type="text" style="display:none; width:10px;" id="maker"/>
			<input class="easyui-textbox " type="text" style="display:none; width:10px;" id="makeTime"/><br>
				<label for="holidayName">假种名称:</label> <input
					class="easyui-validatebox  holidaytext" type="text" id="holidayName"
					placeholder="请输入假种名称  " data-options="required:true" /><br>
				<label for="salary">薪资处理:</label> <select
					class="easyui-combobox holidaytext" id="whetherSalary"
					panelHeight="auto" style="width: 200px">
					<option value="带薪">带薪</option>
					<option value="无薪">无薪</option>
				</select><br> <label for="remark">备 &nbsp &nbsp&nbsp&nbsp注:</label>
				<textarea rows="5" cols="20" class="holidayremaker " id="remark"></textarea>
				<br> <label for="person">个人假种:</label> <input id="personageHoliday"
					type="checkbox"  name="dname" /> <label for="statutory">法定假种:</label>
				<input id="statutoryHoliday" type="checkbox"   name="dname" /> <label
					for="open">启用:</label> <input id="systemUse" type="checkbox"
					checked="true"  name="dname" /> <label for="stop">停用:</label>
				<input class="easyui-validatebox" type="checkbox"  name="dname" />	
			</div>
		</form>
	</div>
		<script src="../hyn/js/check/holidayKind.js"></script>
	<script type="text/javascript">
		$("#huoadd4").linkbutton({
			onClick : function() {
				$("#huodd4").window("open");
			}
		});
		$('#holidayName').validatebox({
		    required: true
		});
		// 定义底部保存，清空，取消按钮
		$('#huodd4').dialog({
			buttons : [ {
				text : '保存',
				iconCls : 'icon-save',
				handler : function() {
					$('#ff').form('submit', {
						onSubmit : function(param) {
							var holidayId= $("#holidayId").val();
							var holidayName = $("#holidayName").val();
							var whetherSalary = ""+$("#whetherSalary").val();
							var remark = $("#remark").val();
							var personageHoliday = ""+$("#personageHoliday").is(":checked");
							var statutoryHoliday =""+ $("#statutoryHoliday").is(":checked");
							var systemUse = ""+$("#systemUse").is(":checked");
							var holidays = [];
						
							if(holidayId==null||holidayId===''){
								var maker = "huohuo"/* ${user} */;
								var holiday = {
										holidayName : holidayName,
										whetherSalary : whetherSalary,
										remark : remark,
										personageHoliday : personageHoliday,
										statutoryHoliday : statutoryHoliday,
										systemUse : systemUse,
										maker : maker	
									};
									holidays.push(holiday);
									var jsondata = JSON.stringify(holidays);
								$.ajax({
									url : "../check/addHolidayKind",
									data : {"jsondata" : jsondata},
									success : function(e) {
										if (e == "ok") {
											alert("存储成功");
			                               $('#huodg4').datagrid('load');
										}
									}
								});
							}
							else{
								var maker = $("#maker").val();	
								var makeTime = $("#makeTime").val();
								var updateEmp =  "huohuo"/* ${user} */;
								var holiday = {
										holidayId: holidayId,
										holidayName : holidayName,
										whetherSalary : whetherSalary,
										remark : remark,
										personageHoliday : personageHoliday,
										statutoryHoliday : statutoryHoliday,
										systemUse : systemUse,
										maker : maker, 
										makeTime:makeTime,
										updateEmp:updateEmp
									};
									holidays.push(holiday);
									var update_jsondata = JSON.stringify(holidays);
								$.ajax({
									url : "../check/updateHolidayKind",
									data : {"update_jsondata" :update_jsondata},
									success : function(e) {
										if (e == "ok") {
											alert("修改成功");
			                               $('#huodg4').datagrid('load');
										}
									}
								});
							}
						},
						success : function(data) {

						}
					});
				}
			}, {
				text : '清空',
				iconCls : 'icon-clear',
				handler : function() {
					$('#ff').form('clear');
				}
			}, {
				text : '取消',
				iconCls : 'icon-cancel',
				handler : function() {
					$("#huodd4").window("close");
				}
			} ]
		});
	</script>
	<!-- 弹出新增窗口代码结束 -->
</body>
</html>